package com.gxa.service.investment.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.dto.investmentDto.IntentionAgreementResult;
import com.gxa.dto.investmentDto.OccupancyRegisterQuitDto;
import com.gxa.entity.investment.OccupancyRegister;
import com.gxa.mapper.investment.OccupancyRegisterMapper;
import com.gxa.service.investment.OccupancyRegisterService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 入驻登记单 服务实现类
 * </p>
 *
 * @author yjl
 * @since 2022-10-17 03:04:36
 */
@Service
public class OccupancyRegisterServiceImpl extends ServiceImpl<OccupancyRegisterMapper, OccupancyRegister> implements OccupancyRegisterService {

    @Autowired
    private OccupancyRegisterMapper occupancyRegisterMapper;

    @Override
    public List<OccupancyRegister> seletAll() {
        return occupancyRegisterMapper.selectList(null);
    }

    @Override
    public OccupancyRegister quitById(Integer id) {
        return occupancyRegisterMapper.selectById(id);
    }

    @Override
    public PageInfo<OccupancyRegister> queryByOccupancyRegisterQuitDto(OccupancyRegisterQuitDto occupancyRegisterQuitDto, Integer pageNum, Integer pageSize) {
        Page<OccupancyRegister> page = PageHelper.startPage(pageNum,pageSize);
        List<OccupancyRegister> intentionAgreementResults = this.occupancyRegisterMapper.queryByInvestmentPlanDto(occupancyRegisterQuitDto);
        PageInfo<OccupancyRegister> pageInfo = new PageInfo<>(intentionAgreementResults);

        return pageInfo;
    }

    @Override
    public void updateToState(Integer id, Integer state) {
        UpdateWrapper updateWrapper = new UpdateWrapper();
        updateWrapper.eq("id",id);
        updateWrapper.set("state", state);
        occupancyRegisterMapper.update(null, updateWrapper);
    }

    @Override
    public void add(OccupancyRegister occupancyRegister) {
        occupancyRegisterMapper.insert(occupancyRegister);
    }
}
